package com.mtbu.bean.base;
import java.util.*;
import java.text.SimpleDateFormat;
import org.json.JSONObject;
import my.json.core.JsonAble;
public abstract class SysFuncBase implements JsonAble {
    private Map<String, Object> dirtyProperties = new HashMap<String, Object>();
    //ID
    private int id = 0;
    //功能ID
    private String funcID = "";
    //功能名称
    private String funcName = "";
    //模块ID
    private String moduleID = "";
    public int getId(){
        return this.id;
    }
    public void setId(int id){
        this.id = id;
    }
    public String getFuncID(){
        return this.funcID;
    }
    public void setFuncID(String funcID){
        this.funcID = funcID;
        dirtyProperties.put("funcID", funcID);
    }
    public String getFuncName(){
        return this.funcName;
    }
    public void setFuncName(String funcName){
        this.funcName = funcName;
        dirtyProperties.put("funcName", funcName);
    }
    public String getModuleID(){
        return this.moduleID;
    }
    public void setModuleID(String moduleID){
        this.moduleID = moduleID;
        dirtyProperties.put("moduleID", moduleID);
    }
    public Map<String, Object> getDirtyProperties() {
        return this.dirtyProperties;
    }
    public JSONObject toJSON() throws Exception {
        JSONObject json = new JSONObject();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        json.put("id", this.getId());
        if(funcID!=null){
           json.put("funcID",this.getFuncID());
        }
        if(funcName!=null){
           json.put("funcName",this.getFuncName());
        }
        if(moduleID!=null){
           json.put("moduleID",this.getModuleID());
        }
        return json;
    }
    public void fromJSON(JSONObject json) throws Exception {
        if(json==null) return;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{
            if(json.get("id") != null){
                this.setId(Integer.parseInt(json.get("id")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("funcID") != null){
                this.setFuncID(json.get("funcID")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("funcName") != null){
                this.setFuncName(json.get("funcName")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("moduleID") != null){
                this.setModuleID(json.get("moduleID")+"");
            }
        }catch(Exception ex){
        }
    }
    public void fromMap(Map<String, String> json) throws Exception {
        if(json==null) return;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            if(json.containsKey("id".toLowerCase())){
                this.setId(Integer.parseInt(json.get("id".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("funcID".toLowerCase())){
                this.setFuncID(json.get("funcID".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("funcName".toLowerCase())){
                this.setFuncName(json.get("funcName".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("moduleID".toLowerCase())){
                this.setModuleID(json.get("moduleID".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
    }
}
